
<template>
<!-- 购买数量子组件 -->
   <div class="mui-numbox" data-numbox-min='1' >
		<button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
		<input id="test" class="mui-input-numbox" type="number" :value="initcount" @change="countChanged" ref="numbox" />
		<button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
	</div>
</template>


<script>
//导入mui
import mui from '../../lib/mui/js/mui.min.js'
export default {
  data(){
	  return {}
  },
  mounted(){
	  //初始化数量子组件
	  mui('.mui-numbox').numbox()
  },
  methods:{
	  countChanged(){
		  //console.log(this.$refs.numbox.value)
		  //每当商品数量有变化时，都更新到store中
		  this.$store.commit("updateCarCount",{id:this.id,count:parseInt(this.$refs.numbox.value)})
	  }
  },
  props:["initcount","id"]
 
 
}
</script>


<style lang="less" scoped>

</style>

